package com.ssau.expert.core.impl;

import java.util.ArrayList;
import java.util.List;

/**
 * Author: Sergey42
 * Date: 10.10.13 21:54
 */
public class Logger {

    private List<String> log = new ArrayList<>();

    public void info(String item) {
        log.add("[Info] : " + item);
    }

    public void info(String item, Object... args) {
        info(String.format(item, args));
    }

    public void error(String item) {
        log.add("[Error] : " + item);
    }

    public void error(String item, Object... args) {
        error(String.format(item, args));
    }

    public void warn(String item) {
        log.add("[Warning] : " + item);
    }

    public void warn(String item, Object... args) {
        warn(String.format(item, args));
    }

    public void addItem(String item) {
        log.add(item);
    }

    protected void clearLog() {
        log.clear();
    }

    public List<String> getLog() {
        return new ArrayList<>(log);
    }

    public static Logger get() {
        return instance;
    }

    private static Logger instance = new Logger();

    private Logger() {
    }
}
